<?php
if(arg(1) == 'edit'&& !empty($_GET['addr_id'])) {
    echo get_template_header_info($_GET['addr_id'], 'village');
}
?>
<style>
    .soil_condition{
        clear: both;
    }
    .soil_condition input{
        width: 500px !important;
    }
</style>
<div class="hp-tab-newprd">
    <?php if(!empty($_GET['farmer_id'])){?>
        <img style="margin-left: 75px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/farmer.png"/>
    <?php }else if(!empty($_GET['addr_id'])){ ?>
        <img style="margin-left: 75px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/village.png"/>
    <?php }?>
    <ul class="j-sw-nav">
        <?php
            if(arg(1) == 'add'){?>
                <li class="newprd-s1 tab-li"><a href="<?php echo base_path(); ?>village/list">查看</a></li>
                <?php if(user_access('add village')){?>
                <li class="newprd-s2 tab-li on"><a href="<?php echo base_path(); ?>village/add">添加</a></li>
            <?php }
            }else if(arg(1) == 'edit'&& !empty($_GET['addr_id'])) {
                 echo get_tab($_GET['addr_id'],'village','village');
                ?>
            <?php }else if(arg(1) == 'edit'&& empty($_GET['addr_id'])){?>
                <li class="newprd-s1 tab-li"><a href="<?php echo base_path(); ?>village/list">查看</a></li>
                <?php if(user_access('add village')){?>
                <li class="newprd-s2 tab-li"><a href="<?php echo base_path(); ?>village/add">添加</a></li>
                <?php }?>
                <li class="newprd-s3 tab-li on"><a href="javascript:void(0)">修改</a></li>
            <?php }?>
    </ul>
        <div class="newprd-s1">
            <div class="table-div">
                <?php  print _address_render_for_add($form)?>

<!--                <div class="small-select small-input column" style="clear:both">-->
<!--                    <div class="form-label">请选经销商:</div>--><?php //print render($form['distributor']); ?>
<!--                </div>-->
                <div class="max-select big-input column" style="clear:both">
                    <?php if( empty($_GET['distributor_id'])) { ?>
                        <div class="max-big-input address-search">
                            <div class="form-label"><span class="required">*</span>请选经销商:</div>
                            <?php print render($form['distributor_name']);
                            print render($form['select_distributor_button']);
                            ?>
                        </div>
                    <?php  } ?>
                </div>
                <div class="small-select small-input column" style="clear:both">
                    <div class="small-div">
                        <div class="form-label"><span class="required">*</span>人口数量:</div><?php print render($form['population']); ?></div>
                </div>
                <div class="small-select small-input column" style="clear:both">
                    <div class="form-label"><span class="required">*</span>人均收入(元):</div><?php print render($form['income_average']); ?>
                </div>
                <div class="small-select small-input column" style="clear:both">

                </div>
                <div class="small-select small-input column" style="clear:both">
                    <div class="small-div">
                        <div class="form-label"><span class="required">*</span>耕地面积(亩):</div><?php print render($form['farm_area']); ?>
                      </div>
                </div>
                <div class="soil_condition">
                    <div class="form-label"><span class="required">*</span>土壤条件:</div><?php print render($form['soil_condition']); ?></div>
                <div class="small-select max-big-input column" style="clear:both">
                    <div class="form-label">专项活动:</div><?php print render($form['special_activities']); ?>
                </div>
                <div style="clear:both">
                    <div class="form-label">其他信息:</div><div style="margin-left: 11.3em; "><?php print render($form['comments']); ?></div>
                </div>

                <?php
//                if(!empty( $form['#addr_id'])){
                    $village_plant_id = 0;
                    foreach( $form['plant']['#value'] as $key=>$value){
                        $html ='<div class="fertilization-div '.$value->village_plant_id.'"><div class="fertilization-title">'.$value->plant_name;
                        $html .= '<span class="fertilization-delete" onclick="ajax_table_delete_item(\'/village/plant/list/delete\',\''.$value->village_plant_id.'\')">-</span></div>';
                        $html .= '<ul><li>作物:'.$value->plant_name."</li>";
                        $html .= '<li>种植面积(亩):'.$value->area."</li>";
                        $html .= '<li>亩产量（千克/亩）:'.$value->acre_yield."</li>";
                        $html .= '<li>价格（元/千克）:'.$value->price."</li></ul></div>";
                        $village_plant_id = $value->village_plant_id;
                        print render($html);
                    }
//                }

                ?>
                <?php
//                if(!empty($form['#addr_id'])){
                    ?>
                <div class="fertilization-div add-fertilization-div"
                     id='add-fertilizer-info' data-toggle="modal"
                     data-target="#villagePlantModal">
                    <div class="fertilization-title"><span style="font-weight: bold">继续添加主要作物</span></div>
                    <span class="add-fertilization">+</span>
                </div>
<!--                --><?php
//                } ?>
                <div class="add-submit" style="text-align: center"><?php print render($form['submit']); ?></div>

            </div>
        </div>
    </div>

    <?php print drupal_render_children($form); ?>

</div></form>
<div>
    <div class="modal fade" id="villagePlantModal" tabindex="-1" role="dialog" aria-labelledby="villagePlantModal" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        主要作物
                    </h4>
                </div>
                <div class="modal-body">
                    <?php echo @render(drupal_get_form('village_plant_modal_form',$form['#addr_id']));?>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>

<div>
    <div class="modal fade" id="distributorModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        选择经销商
                    </h4>
                </div>
                <div class="modal-body">
                    <?php echo @render(drupal_get_form('distributor_select_list_form'),$_GET['addr_id']?$_GET['addr_id']:'');?>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">关闭
                    </button>

                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>
<form><div>